class StudCards {
    constructor(id) {

        this.bodyId = id;//卡片部分的盒子id

        this.pageInd = 1;
        this.rowCount = 0x3f3f3f3f;

        this.studTab = new StudTab();

        this.sid = '';

        this.studCardDetail = new StudCardDetail("id-layui-body-stud-details","id-layui-body-stud-details-table");

        this.studChooseCourse = new StudChooseCourse("id-layui-body-stud-details","id-layui-body-stud-details-choose-Course-table","filter-stud-details-choose-Course-table");

    }

    start() {

        let load = this;
       
        $("#" + this.bodyId).show().siblings().hide();

        load.render();
        



    }

    render(){

        let load = this;

        $.get("/Lock/GetSomeAcc",
            { pageInd: load.pageInd, rowCount: load.rowCount, accrank: 3 },
            function (req) {
                console.log(req);
                load.renderStudCard(req.students);
            }
        )


       

    };

    // 根据响应报文渲染卡片
    renderStudCard(req) {
        console.log("-------------- renderManageStudCard ----------------")

        // var template = require('art-template');

        var htmlstr = "";

        for (let i = 0; i < req.length; i++) {
            if (i % 4 == 0) {
                if (i != 0) htmlstr += "</div>";
                htmlstr += " <div class=\"stud-col layui-row \">";
            }
            console.log(req[i]);
            htmlstr += template("tp-admin-side-acc-manage-stud-card", req[i]);

        }

        $("#admin-body-stud-tab-Card").html(htmlstr);

        for (let i = 0; i < req.length; i++) {
            $(".admin-mg-stud-card")[i].tid = req[i].aid;
        }


        this.addEvent();
        console.log("-------------- renderManageStudCard end ----------------")
    }

    addEvent(){

        let load = this;

       

        $(".admin-mg-stud-card").on("click",function(){
            console.log("cilck");
            console.log("addEvent");
            console.log(this);


            load.sid = this.id;

            load.studCardDetail.start(this.id);
            
        })


        layui.element.on('tab(filter-layui-body-stud-details-tab)', function(data){
           
            let index = data.index; 
            if(index == 0){
                load.studCardDetail.start(load.sid);
            }else if(index == 1){
                console.log("click");
                load.studChooseCourse.start(load.sid);
            }
          });

    }

    // }
}